<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
     <script>
        // 将函数作为参数传递给其他函数，在外部函数中调用它
        function print(callback){
            callback();
        }


        // 创建回调函数
        const message = function(){
            console.log("This message is shown after 3 seronds");
        }
        setTimeout(message,300);

        
        // 箭头函数
        // 箭头函数不绑定this关键字，箭头函数中的this，指向的事函数定义位
        var object = {
            uname:"张三",age:21
        }
        function fn(){
            console.log(this,"外层函数");
            return()=>{
                console.log(this,"箭头函数");
            }
            let result = fn.call(obj)
            result()
        }


        // 判断this指向
        var age=100;
        var obj = {
            age:20,
            say:()=>{
                alert(this.age)
            }
        }
        obj.say()
     </script>
</body>
</html>